#include<iostream>
#include<queue>
#include<vector>
using namespace std;
const int N = 1e6 + 10;
int fun(int a, int b, int c,int x)
{
	return a * x * x + b * x + c;
}
int main()
{
	vector<int> ha[N];int xi[4];
	priority_queue<int,vector<int>,greater<int>> tree;
	int count = 0,n, m;cin >> n >> m;
	for (int i = 1; i <= n; i++)
	{
		int a, b, c;cin >> a >> b >> c;
		ha[i].push_back(a);
		ha[i].push_back(b);
		ha[i].push_back(c);
	}
	for (int i = 1; i <= n; i++)
	{
		int j = 0;
		for (auto v : ha[i])
		{
			xi[j] = v;
			j++;
		}
		int ret = fun(xi[0],xi[1],xi[2],)
	}
	while (tree.size())
	{
		cout << tree.top() << ' ';
		tree.pop();
	}
	return 0;
}